package com.gitee.feizns.quickstart.ding.talk.api.top.api.v2.user;

import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiV2UserDeleteRequest;
import com.dingtalk.api.response.OapiV2UserGetResponse;
import com.gitee.feizns.quickstart.ding.talk.utils.Utils;
import lombok.SneakyThrows;

/**
 * 删除用户（/topapi/v2/user/delete）
 * 接口路径：<a href="https://open.dingtalk.com/document/orgapp/delete-a-user">删除用户（/topapi/v2/user/delete）</a>
 * @link <a href="https://open.dingtalk.com/document/orgapp/delete-a-user">服务端API 通讯录管理 用户管理 删除用户</a>
 * @author feizns
 * @since 2025/3/24
 */
public class Delete {

    /**
     * 执行
     * @param accessToken 访问令牌
     * @param userid 用户 ID
     * @return {@link OapiV2UserGetResponse.UserGetResponse }
     */
    @SneakyThrows
    public static String execute(String accessToken, String userid) {
        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/delete");
        OapiV2UserDeleteRequest req = new OapiV2UserDeleteRequest();
        req.setUserid(userid);
        return Utils.ifErrorThrow(client.execute(req, accessToken)).getBody();
    }

}
